<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Off the Record</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">


</head>
<script type="text/javascript">
	function checkForm() {
		var f = document.loginForm;

		if (f.id.value == "") {
			alert("아이디를 입력해 주세요.");
			f.id.focus();
			return false;
		}
		if (f.password.value == "") {
			alert("비밀번호를 입력해 주세요.");
			f.password.focus();
			return false;
		}

		if (f.id.value != "" && f.password.value != "") {
			$.ajax({
				type : "post",
				url : "/OffTheRecord/login.action",
				data : "id=" + $('#id').val() + "&&password="
						+ $('#password').val(),
				dataType : "json",

				success : function(data) {
					if (data.flag == false) {
						alert("아이디 또는 비밀번호가 일치하지 않습니다.");
						$('#id').val("");
						$('#password').val("");
					} else {
						window.opener.parent.location.reload();
						window.opener.document.location.reload();
						self.close();
					}
				}
			});//ajax
		}
	}
</script>
<body>
	<div class="container">
		<div class="row">

			<!--  -->
			<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
				style="border: 1px solid lightgray; border-radius: 5px; padding: 10px;">
				<form class="form" action="/OffTheRecord/login.action" method="post"
					name="loginForm">
					<div class="form-group">
						<label for="user_id">아이디</label> <input type="text"
							class="form-control" id="id" name="id" placeholder="아이디을 입력해주세요.">
					</div>

					<div class="form-group">
						<label for="password">비밀번호</label> <input type="password"
							class="form-control" id="password" name="password"
							placeholder="비밀번호을 입력해주세요.">
					</div>

					<input class="btn btn-default" type="button" value="로그인" onclick="checkForm()">
					<p>
					<div>
						<a href="/OffTheRecord/user/register.jsp">회원가입</a><br> <a
							href="/OffTheRecord/user/find_user.jsp">아이디/비밀번호 찾기</a>
					</div>
				</form>
			</div>
			<!--  -->

		</div>
		<!-- row -->
	</div>
	<!-- container -->
	<script
		src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
	<script
		src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>
</html>